<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .red {
        color: red;
      }
      .font30 {
        font-size: 30px;
      }
    </style>
  </head>
  <body>
    <div class="container">
      Lorem ipsum, dolor sit amet consectetur adipisicing elit. Doloribus nesciunt rem eligendi corporis et dicta
      consequatur facilis nostrum vero cum, earum beatae aspernatur natus sint doloremque hic debitis atque dolor.
    </div>
    <script>
      const oContainer = document.querySelector('.container')
      // setAttribute 可以设置多个
      oContainer.setAttribute('class', 'red font30') // 直接覆盖原来的class值，然后重新赋值
      oContainer.setAttribute('disabled', '')
      oContainer.setAttribute('data-key', 'abcdef01')
      // oContainer.classList.add('red')

      // getAttribute 只有一个参数，获取class属性的值
      console.log(oContainer.getAttribute('class'))

      // removeAttribute 只有一个参数，class 属性直接被移除
      setTimeout(() => {
        oContainer.removeAttribute('class')
      }, 3000)
      // oContainer.removeAttribute('class', 'font30')
    </script>
  </body>
</html>
